<?php 
	require_once("utils.php");
	require_once("obj/session.php");
	require_once("obj/user.php");
	require_once("obj/report.php");
	
	if(isset($_POST["selMonth"]))
	{ 
		$month = $_POST["selMonth"];		
		$report = Report::userMonthlyTotals($session->UserId,$month);
	}
	else if(isset($_POST["txtEmail"]))
	{ 
		$email = $_POST["txtEmail"];		
		$report = Report::selectUserMonthlyTotals($email);
	}
	else
	{
		$reportID = $_GET["reportid"];
		$report = Report::generate($reportID,$session->UserId);
	}

?>
<table class="datatable" width="100%" cellpadding="5" cellspacing="0">
<tr><th>Name</th><th>Description</th><th>Data</th><th>&nbsp;</th></tr>
<?php

	if(count($report) > 0)
	{	
		$ix = 0;
		foreach($report as $r){
			$n = $r->Name;
			$d = $r->Description;
			$v = $r->Value;
			$cs = $ix % 2 == 0 ? "row" : "altrow";
			echo "<tr class=\"$cs\"><td>$n</a></td><td>$d</td><td>$v</td></tr>";
			$ix++;
		}
	}
	else
	{
		echo "<tr class=\"$cs\"><td>No Values Returned</a></td><td>&nbsp;</td><td>&nbsp;</td></tr>";
	}
?>
</td>
</table>
